﻿using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

        Page.GetPostBackEventReference(Page);
          
        if (IsPostBack)
        {
            if (Request.Params.Get("__EVENTTARGET") == "button1")
            {
                Conexion cu = new Conexion();
                string prueba = Request.Params.Get("__EVENTTARGET");

                int id = cu.loginInto(txtUser.Value.ToString(), txtPassword.Value.ToString());
                if (id != 0)
                {

                    Session["txtUserName"] = txtUser.Value.ToString();
                    Session["idUser"] = id.ToString();
                    Response.Redirect("Main.aspx");
                }
                else
                {
                    Response.Redirect("Login.aspx");
                    
                }
                 
                }

                    }

        

    }
}
